package com.hzhr.iot.collect.controller;

import com.hzhr.iot.collect.controller.base.BaseController;
import com.hzhr.iot.collect.model.collectLog.CollectLogGetModel;
import com.hzhr.iot.collect.service.CollectLogService;
import com.hzhr.iot.core.annotation.ApiImplicitInternalParams;
import com.hzhr.iot.core.annotation.Author;
import com.hzhr.iot.core.annotation.CygQuery;
import com.hzhr.iot.core.annotation.CygQuerys;
import com.hzhr.iot.core.exception.ServiceException;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@Api(tags = "CollectLog", description = "采集日志")
@RestController
@RequestMapping(value = "")
@CygQuerys({
        @CygQuery(name = "_equal_id", query = "equal_id", type = Integer.class),
        @CygQuery(name = "_equal_collectDeviceId", query = "equal_collectDeviceId", type = Integer.class),
        @CygQuery(name = "_equal_iotDeviceId", query = "equal_iotDeviceId", type = Integer.class),
        @CygQuery(name = "_equal_iotDeviceCode", query = "equal_iotDeviceCode", type = String.class),
        @CygQuery(name = "_like_iotDeviceCode", query = "like_iotDeviceCode", type = String.class),
})
public class CollectLogController extends BaseController {
    @Autowired
    CollectLogService collectLogService;

    //region /collect-logs GET
    //region swagger响应码 : get
    @ApiResponses({
            @ApiResponse(code = 200, message = "成功"),
    })
    //endregion
    //region swagger说明 : get
    @ApiOperation(value="查询报警数据", notes="查询报警数据  \n范围 : 无  \n步骤 :  \n1. 查询报警数据; (√)  \n",produces = "application/json")
    //endregion
    //region swagger参数 : get
    @ApiImplicitParams({
            @ApiImplicitParam(name = "token", value = "令牌",required = true, dataType = "string", paramType = "header"),

            @ApiImplicitParam(name = "show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_id", value = "筛选条件 : where CollectLogModel.id = #{equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_collectDeviceId", value = "筛选条件 : where CollectLogModel.collectDeviceId = #{equal_collectDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_iotDeviceId", value = "筛选条件 : where CollectLogModel.iotDeviceId = #{equal_iotDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_iotDeviceCode", value = "筛选条件 : where CollectLogModel.iotDeviceCode = #{equal_iotDeviceCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "like_iotDeviceCode", value = "筛选条件 : where CollectLogModel.iotDeviceCode like #{like_iotDeviceCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_functionCode", value = "筛选条件 : where CollectLogModel.functionCode = #{equal_functionCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "equal_starter", value = "筛选条件 : where CollectLogModel.starter = #{equal_starter}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "equal_type", value = "筛选条件 : where CollectLogModel.type = #{equal_type}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "greaterthanorequal_startTime", value = "筛选条件 : where CollectLogModel.startTime >= #{greaterthanorequal_startTime}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "lessthan_startTime", value = "筛选条件 : where CollectLogModel.startTime < #{lessthan_startTime}",required = false, dataType = "int", paramType = "query"),

    })
    @ApiImplicitInternalParams({
            @ApiImplicitParam(name = "_token", value = "令牌",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-id", value = "用户编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-code", value = "用户代码",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-name", value = "用户名",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-company-id", value = "公司编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-dept-id", value = "部门编号",required = true, dataType = "int", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-user-type", value = "用户类型(关联: common_service.options.code, typeCode = 'USER_TYPE')",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-id", value = "交易流水号",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-transaction-type", value = "交易类型",required = true, dataType = "string", paramType = "header"),
            @ApiImplicitParam(name = "_hzhr-access-mode", value = "访问模式 0:一般 1:全局",defaultValue = "0", required = false, dataType = "int", paramType = "header"),

            @ApiImplicitParam(name = "_show", value = "展示形式 one:展示一个,list:展示列表,null(空值):不展示", required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_show_total", value = "是否展示总数", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_show_info", value = "是否展示详情", defaultValue = "false", required = false, dataType = "boolean", paramType = "query"),
            @ApiImplicitParam(name = "_page", value = "页数", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_count", value = "每页数量", defaultValue = "1",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_id", value = "筛选条件 : where CollectLogModel.id = #{_equal_id}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_collectDeviceId", value = "筛选条件 : where CollectLogModel.collectDeviceId = #{_equal_collectDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_iotDeviceId", value = "筛选条件 : where CollectLogModel.iotDeviceId = #{_equal_iotDeviceId}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_iotDeviceCode", value = "筛选条件 : where CollectLogModel.iotDeviceCode = #{_equal_iotDeviceCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_like_iotDeviceCode", value = "筛选条件 : where CollectLogModel.iotDeviceCode like #{_like_iotDeviceCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_functionCode", value = "筛选条件 : where CollectLogModel.functionCode = #{equal_functionCode}",required = false, dataType = "string", paramType = "query"),
            @ApiImplicitParam(name = "_equal_starter", value = "筛选条件 : where CollectLogModel.starter = #{equal_starter}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_equal_type", value = "筛选条件 : where CollectLogModel.type = #{equal_type}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_greaterthanorequal_startTime", value = "筛选条件 : where CollectLogModel.startTime >= #{greaterthanorequal_startTime}",required = false, dataType = "int", paramType = "query"),
            @ApiImplicitParam(name = "_lessthan_startTime", value = "筛选条件 : where CollectLogModel.startTime < #{lessthan_startTime}",required = false, dataType = "int", paramType = "query"),

    })
    //endregion
    //region 请求 : get
    @RequestMapping(value = "/collect-logs", method = RequestMethod.GET)
    //endregion
    @Author
    public ResponseEntity<CollectLogGetModel> get(@RequestParam @ApiIgnore Map<String, Object> query) throws ServiceException {
        CollectLogGetModel responseBody = collectLogService.get(initHeader(), query);
        return new ResponseEntity<>(responseBody, HttpStatus.OK);
        //endregion
    }
    //endregion
}


















































